import { create } from "zustand";

interface LanguageState {
  language: string; // 当前语言
  isMenuOpen: boolean; // 是否打开语言菜单
  changeLanguage: (lang: string) => void; // 切换语言
  toggleMenu: (open: boolean) => void; // 打开或关闭菜单
}

export const useLanguageStore = create<LanguageState>((set) => ({
  language: "en", // 默认语言
  isMenuOpen: false, // 默认菜单关闭
  changeLanguage: (lang) => {
    console.log("切换语言为：", lang); // 日志验证
    set(() => ({ language: lang }));
  },
  toggleMenu: (open) =>
    set(() => ({
      isMenuOpen: open,
    })),
}));
